Skip to content

Conversation

@jmgasper
Copy link
Collaborator

No description provided.

@jmgasper jmgasper merged commit 694a16c into develop Nov 17, 2025
4 checks passed

const challengeId = (queryDto.challengeId ?? '').trim();
if (!challengeId) {
throw new BadRequestException({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The BadRequestException is thrown with a custom message and code. Ensure that this exception handling is consistent with the rest of the application and that the client is prepared to handle this specific error code (TSV_CHALLENGE_ID_REQUIRED).

}

private requestWantsTabSeparated(req: Request): boolean {
const acceptHeader = Array.isArray(req.headers.accept)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The acceptHeader is processed by joining it with a comma if it's an array. Ensure that this behavior aligns with how the rest of the application handles multi-value headers, as this could lead to unexpected results if the header is not handled consistently.


const lines = [headers.join('\t')];

payload.data.forEach((entry) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The forEach loop inside buildReviewSummationTsv processes each entry's metadata. Consider handling potential errors or unexpected data structures within entry.metadata to prevent runtime exceptions.

}

const record = value as Record<string, unknown>;
const hasScore = Object.prototype.hasOwnProperty.call(record, 'score');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 readability]
The use of Object.prototype.hasOwnProperty.call is correct for checking properties. However, consider using TypeScript's optional chaining and nullish coalescing operators for cleaner and more readable code.


const primitiveValue = value as string | number | boolean | bigint;
const asString = String(primitiveValue);
return asString.replace(/[\t\n\r]+/g, ' ');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ security]
The replace method is used to sanitize values by replacing tabs, newlines, and carriage returns. Ensure that this sanitization is sufficient for all expected input data, especially if the data can come from untrusted sources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants